home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 6611 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: news.mindspring.com!usenet
  2. From: efried@mindspring.com (Eric Friedman)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: How to delete array of pointers?
  5. Date: Sat, 10 Feb 1996 07:31:09 GMT
  6. Organization: MindSpring Enterprises
  7. Message-ID: <4fh71r$3cu@brickbat.mindspring.com>
  8. References: <4fgvsu$5q4@eng_ser1.erg.cuhk.hk>
  9. NNTP-Posting-Host: efried.mindspring.com
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. ywleung@cs.cuhk.hk (Marty McFly) wrote:
  13.  
  14. >If I write the following code in a function:
  15.  
  16. >    int** ptr;
  17. >    ptr = new int*[1000];
  18.  
  19. >Is this code means allocating 1000 integer pointers which is pointed by ptr?
  20. >And then somehow I assign integer variable to ptr[0], ptr[1], ... and so on.
  21. >So at the end of the function, how can I reclaim just those pointers?  The key
  22. >point is that those integer variable assigned to the pointers should not be 
  23. >deleted.
  24.  
  25. There is no way to deallocate a subset of the array. You could copy
  26. the contents of the elements you want to keep to another array, or use
  27. the standard C functions mallaoc and realloc
  28. -------------------------------------------------------
  29. Eric Friedman        Internet: efried@mindspring.com
  30.  
  31.